<template>
  <div>
    <el-card>
      <div class="new-music-head">
        <div class="head-btn-wrap">
          <button
            class="btn-newmusic"
            :class="{ 'btn-newmusic_active': dIndex === 0 }"
            @click="changeIndex(0)"
          >
            新歌速递
          </button>
          <button
            class="btn-newmusic"
            :class="{ 'btn-newmusic_active': dIndex === 1 }"
            @click="changeIndex(1)"
          >
            新碟上架
          </button>
        </div>

      </div>
      <div class="mtop-20">
        <component :is="compIndex"/>
      </div>
    </el-card>
  </div>
</template>

<script>
import NewMusic from "@/components/newMusic/newMusic";
import NewAlbum from "@/components/newMusic/newAlbum";
export default {
  components: {
    NewMusic,
    NewAlbum,
  },
  data() {
    return {
      compType:['NewMusic','NewAlbum'],
      dIndex: 0,
    };
  },
  computed:{
    compIndex(){
        return this.compType[this.dIndex];
    }
  },
  methods: {
    changeIndex(index) {
      this.dIndex = index;
    },
  },
};
</script>

<style lang="less" scoped>
.new-music-head {
  display: flex;
  justify-content: center;
  align-items: center;
  .head-btn-wrap {
    width: 202px;
    height: 32px;
    border: 1px solid #bbbbbb;
    border-radius: 16px;
    .btn-newmusic {
      width: 100px;
      height: 30px;
      outline: 0;
      border: 0;
      border-radius: 15px;
      box-sizing: border-box;
      color: #373737;
      background-color: #fff;
      transition: all 0.5s;
      &:hover {
        background-color: #f4f4f4;
      }
    }
    .btn-newmusic_active {
      background-color: #bbbbbb;
      color: #fff;
      &:hover {
        background-color: #bbbbbb;
      }
    }
  }
}
</style>